package yamen.bdwm.datastruct;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

import android.content.Context;

public class WmList {
	public ArrayList<WmItem> list;
	protected HashMap<Integer,WmDataAdapter> adapterList;
	public WmList() {
		list=new ArrayList<WmItem>();
		adapterList=new HashMap<Integer, WmDataAdapter>();
	}
	//HashMap<K, V>
	public void NotifyAllAdapter()
	{
		Set<Integer> set= adapterList.keySet();
		Object[] array=set.toArray();
		for(int i=0;i<set.size();i++)
		{
			WmDataAdapter adapter;
			adapter=adapterList.get(array[i]);
			if(adapter!=null)
				adapter.notifyDataSetChanged();
		}
	}
	public void CreateAdapter(int tag,int resource)
	{
		if(!adapterList.containsKey(tag))
		{
			WmDataAdapter adapter=new WmDataAdapter(resource, this);
			adapterList.put(tag, adapter);
		}	
	}
	public void Clear()
	{
		list.clear();
	}
	public WmDataAdapter getAdapter(int tag,Context context)
	{	
		WmDataAdapter adapter=adapterList.get(tag);
		adapter.setContext(context);
		return adapter;
	} 
	public int Add(WmItem item)
	{
		list.add(item);
		return 1;
	}
}
